//
//  NetEngine.h
//  testpb
//
//  Created by zhangjimin on 15/7/26.
//  Copyright (c) 2015年 zhangjimin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "head.pb.h"

@class GCDAsyncSocket;
@class Request;


@protocol PushDelegate <NSObject>
-(void) onPush:(Packet *)packet;
-(void) onConnConnect;
-(void) onConnDisconnect;
@end



@interface NetEngine : NSObject


/**
 *  单例
 *
 *  @return self
 */
+(instancetype) shareInstance;

/**
 *  重设host 和port
 *
 *  @param hostStr
 *  @param portStr
 */
- (void)resetHost:(NSString *)hostStr andPort:(NSString *)portStr;
- (NSString *)hostStr;
- (NSString *)portStr;

/**
 *  请求方式
 *
 *  @param request 包含packet的请求类
 */
- (void)sendRequest:(Request*)request;

/**
 *  断开
 */
- (void)heartbeatFail;

/**
 *  engine的代理
 */
@property (nonatomic ,weak)id<PushDelegate> pushDelegate;


-(void) enable;
-(void) disable;

@end
